import com.item.spring.jdbc.dao.EmployeeDao;
import com.item.spring.jdbc.entity.Employee;
import com.item.spring.jdbc.service.EmployeeService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @RunWith+ @ContextConfiguration作用= ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
 *
 */
@RunWith(SpringJUnit4ClassRunner.class) //JUnit 控制权交给spring
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class JdbctemplateTestor {
    @Resource
    private EmployeeDao employeeDao;
    @Resource
    private EmployeeService employeeService;
    @Test
    public void textFindById(){
        Employee byId = employeeDao.findById(3308);
        System.out.println(byId);
    }

    @Test
    public void findByName(){
        List<Employee> list = employeeDao.findByName("研发部");
        System.out.println(list);
    }

    @Test
    public void findMapByName(){
        List<Map<String, Object>> map = employeeDao.findMapByName("研发部");
        System.out.println(map);
    }

    @Test
    public void testBatchImport(){
        employeeService.batchImport();
        System.out.println("批量导入成功");
    }
}
